import request from 'umi-request';

export async function getSalaryChangePage(params = {},approveStatus,status) {
  let {current, pageSize, ...restParams} = params;
  return request('/hr-ssc/api/api-admin/salary/getSalaryChangePage', {
    method: 'get',
    params: {
      approveStatus,
      status,
      pageSize,
      pageNum: params.current,
      ...restParams
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function getSalaryChangeConfirmPage(params = {},approveStatus,status) {
  let {current, pageSize, ...restParams} = params;
  return request('/hr-ssc/api/api-admin/salary/getSalaryChangeConfirmPage', {
    method: 'get',
    params: {
      approveStatus,
      status,
      pageSize,
      pageNum: params.current,
      ...restParams
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function saveAndUpdateSalaryChange(params) {
  return request('/hr-ssc/api/api-admin/salary/saveAndUpdateSalaryChange', {
    method: 'POST',
    data: {
      ...params,
    },
  }).then(( res) => {
    return res;
  });
}


export async function deleteSalaryChange(id) {
  return request('/hr-ssc/api/api-admin/salary/deleteSalaryChange', {
    method: 'DELETE',
    params: {id}
  }).then(( res) => {
    return res;
  });
}


export async function queryComputerList(params,type) {
  return request('/hr-ssc/api/api-admin/salary/getComputerSubsidyPage', {
    method: 'get',
    params: {
      pageNum: params.current,
      approveStatus:[0,1,2],
      ...params,
      type:type
    },
  }).then((res) => {
    if (res.flag) {
      const data = res.data;
      return {
        current: data.currPage,
        data: data.list,
        pageSize: data.pageSize,
        success: true,
        total: data.totalCount,
      };
    } else {
      return {};
    }
  });
}

export async function saveOrUpdateCredential(data) {
  return request('/hr-ssc/api/api-admin/salary/saveAndUpdateComputerSubsidy', {
    method: 'post',
    data:data,
  }).then(res => res);
}

export async function memberSubsidyBpm(id) {
  return request('/hr-ssc/api/api-admin/bpm/subsidyBpm', {
    method: 'get',
    params: {id},
    requestType: 'form'
  }).then((res) => {
    return res;
  });
}

export async function daleteComputerSubsidy(id){
  return request('/hr-ssc/api/api-admin/salary/daleteComputerSubsidy', {
    method: 'delete',
    params:{id},
  }).then(res => res);
}
